﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>跟进历史管理</title>
    <!-- freemaker：引入模板文件，使用相对路径 来引用 ; .. 上一级目录views -->
    <#include "../common/link.ftl">

    <script>
        $(function () {
            // 新增/编辑按钮点击事件
            $(".btn-input").click(function () {
                $("#traceForm input").val('');
                var data = $(this).data("json");
                if(data){
                    $("#myModalLabel").html("跟进历史编辑");
                    $("input[name='id']").val(data.id);
                    $("input[name='customer.id']").val(data.customerId);
                    $("input[name='customer.name']").val(data.customerName);
                    $("input[name='traceTime']").val(data.traceTime);
                    $("input[name='traceDetails']").val(data.traceDetails);
                    $("select[name='traceType.id']").val(data.traceTypeId);
                    $("input[name='traceResult']").val(data.traceResult);
                    $("select[name='type']").val(data.type);
                }
                // 打开模态框
                $("#traceModal").modal('show');
            });

            // 保存
            $(".traceSubmit").click(function () {
                // 使用 jQuery-form 插件来提交异步表单（有表单的时候）
                $("#traceForm").ajaxSubmit(handleMessage2);
            });
        })

    </script>

</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <!-- 页面的头部内容回显 -->
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="customerTraceHistory"/>
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>跟进历史管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/customerTraceHistory/list.do" method="post">
                    <!-- 分页的隐藏域 当前页 -->
                    <input type="hidden" name="currentPage" id="currentPage" value="1">
                    <div class="form-group">
                        <label for="keyword">关键字:</label>
                        <input type="text" class="form-control" id="keyword" name="keyword" value="${qo.keyword!}" placeholder="请输入姓名">
                    </div>
                    <div class="form-group">
                        <label for="type"> 跟进类型:</label>
                        <select class="form-control" id="typeQuery" name="typeQuery">
                            <option value="-1">全部</option>
                            <option value="0">潜在客户</option>
                            <option value="1">正式客户</option>
                        </select>
                        <script>
                            $("#typeQuery").val(${qo.typeQuery!});
                        </script>
                    </div>
                    <button id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span> 查询</button>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>姓名</th>
                            <th>跟进日期</th>
                            <th>跟进内容</th>
                            <th>跟进方式</th>
                            <th>跟进结果</th>
                            <th>录入人</th>
                            <th>跟进类型</th>
                            <th>操作</th>
                        </tr>
                            <#list result.list as customerTraceHistory>
                            <tr>
                                <!-- freemarker 如果取值时是空值 会报错 -->
                                <td>${customerTraceHistory_index + 1}</td>  <!-- 索引（从0开始）,注意：是_ 不是. -->
                                <td>${(customerTraceHistory.customer.name)!}</td>
                                <td>${(customerTraceHistory.traceTime?string("yyyy-MM-dd"))!}</td>
                                <td>${customerTraceHistory.traceDetails!}</td>
                                <td>${(customerTraceHistory.traceType.title)!}</td>
                                <td>${customerTraceHistory.traceResult!}</td>
                                <td>${(customerTraceHistory.inputUser.name)!}</td>
                                <td>${customerTraceHistory.typeName!}</td>
                                <td>
                                <#-- 使用 data-* 属性来嵌入自定义数据，单引号 -->
                                    <a href="#"
                                       class="btn btn-info btn-xs btn-input" data-json='${customerTraceHistory.json!}'>
                                        <span class="glyphicon glyphicon-pencil"></span> 编辑
                                    </a>
                                </td>
                            </tr>
                            </#list>
                    </table>
                    <!--分页-->
                    <#include "../common/page.ftl">
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl">
</div>

#--跟进历史-->
<div class="modal fade" id="traceModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">跟进编辑</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/customerTraceHistory/saveOrUpdate.do" method="post" id="traceForm">
                <#--新增,新增跟进历史没有ID,客户应该要有ID,不然就不知道当前是哪个客户的跟进历史-->
                    <input type="hidden" name="id"/>
                    <div class="form-group" >
                        <label class="col-lg-4 control-label">客户姓名：</label>
                        <div class="col-lg-6">
                            <input type="hidden" name="customer.id"/>
                            <input type="text" class="form-control" readonly name="customer.name"/>
                        </div>
                    </div>
                    <div class="form-group" >
                        <label class="col-lg-4 control-label">跟进时间：</label>
                        <div class="col-lg-6 ">
                            <input type="text" class="form-control "  name="traceTime" placeholder="请输入跟进时间">
                        </div>
                    </div>
                    <div class="form-group" >
                        <label class="col-lg-4 control-label">跟进记录：</label>
                        <div class="col-lg-6">
                            <input type="text" class="form-control" name="traceDetails"
                                   placeholder="请输入跟进记录"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">交流方式：</label>
                        <div class="col-lg-6">
                            <select class="form-control" name="traceType.id">
                                <#list communicationMethods as c>
                                    <option value="${c.id}">${c.title}</option>
                                </#list>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">跟进结果：</label>
                        <div class="col-lg-6">
                            <select class="form-control" name="traceResult">
                                <option value="3">优</option>
                                <option value="2">中</option>
                                <option value="1">差</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group" >
                        <label class="col-lg-4 control-label">备注：</label>
                        <div class="col-lg-6">
                            <textarea type="text" class="form-control" name="remark"></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">跟进类型：</label>
                        <div class="col-lg-6">
                            <select class="form-control" name="type" id="type">
                                <option value="0">潜在客户开发</option>
                                <option value="1">正式客户跟进</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary traceSubmit">保存</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>
